package com.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Arrays;

@WebServlet("/register")
public class RegisterServlet extends HttpServlet {
        @Override
        protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
            String username = req.getParameter("username");
            String password = req.getParameter("password");
            String sex = req.getParameter("sex");
            String address = req.getParameter("address");
            String[] hobbies = req.getParameterValues("hobby");

            System.out.println(username);
            System.out.println(password);
            System.out.println(sex);
            System.out.println(address);
            System.out.println(Arrays.toString(hobbies));

            resp.setContentType("text/html;charset=utf-8");
            resp.getWriter().write("success");
        }

        @Override
        protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        }
    }

